<div class="alert alert-danger" ng-if="error">
	<b>Error:</b> {{ error }}
</div>
<div class="container">
	<div class="row">
		<div class="col-md-12 text-center" >
			<form class="bottom-margin">
				<button class="btn btn-default" ng-click="dumpThreads()"><i class="icon-screenshot"></i> Dump all threads!</button>
			</form>
		</div>
	</div>
	<div class="row" ng-show="threadStats" >	
		<div class="col-md-12">
			<div class="progress">
				<div ng-if="threadStats.NEW  &gt; 0" class="progress-bar progress-bar-info" style="width:{{ threadStats.NEW / threadStats.total * 100 | number:0 }}%;">
		              New {{ threadStats.NEW }}
				</div>
				<div ng-if="threadStats.RUNNABLE &gt; 0" class="progress-bar progress-bar-success" style="width:{{ threadStats.RUNNABLE / threadStats.total * 100 | number:0 }}%;">
		              Runnable {{ threadStats.RUNNABLE }}
				</div>
				<div ng-if="threadStats.BLOCKED &gt; 0" class="progress-bar progress-bar-danger" style="width:{{ threadStats.BLOCKED / threadStats.total * 100 | number:0 }}%;">
		              Blocked {{ threadStats.BLOCKED }}
				</div>
				<div ng-if="threadStats.WAITING &gt; 0" class="progress-bar progress-bar-warning" style="width:{{ threadStats.WAITING / threadStats.total * 100 | number:0 }}%;">
		              Waiting {{ threadStats.WAITING }}
				</div>
				<div ng-if="threadStats.TIMED_WAITING &gt; 0" class="progress-bar progress-bar-warning progress-bar-striped" style="width:{{ threadStats.TIMED_WAITING / threadStats.total * 100 | number:0 }}%;">
		             Timed waiting {{ threadStats.TIMED_WAITING }}
				</div>
				<div ng-if="threadStats.TERMINATED &gt; 0" class="progress-bar progress-bar-info" style="width:{{ threadStats.TERMINATED / threadStats.total * 100 | number:0 }}%;">
		             Terminated {{ threadStats.TERMINATED }}
				</div>
			</div>
		</div>
	</div>	
	<div class="row" ng-show="dump">
		<div class="col-md-12">
			<accordion close-others="true">
				<accordion-group ng-repeat="thread in dump | orderBy:'threadName' track by thread.threadId">
					<accordion-heading>
						<small class="muted">{{thread.threadId}}</small>
						{{thread.threadName}}
						<span class="pull-right label label-default" ng-class="{ 'label-info': thread.threadState == 'NEW', 'label-success': thread.threadState == 'RUNNABLE', 'label-important': thread.threadState == 'BLOCKED', 'label-warning': thread.threadState == 'TIMED_WAITING' ||  thread.threadState == 'WAITING', 'label-info': thread.threadState == 'TERMINATED'}">{{thread.threadState}}</span> <span class="label label-warning"  ng-if="thread.suspended">suspended</span>
					</accordion-heading>
					<div class="container-fluid">
						<div class="row" >
								<table class="col-md-6">
									<colgroup>
										<col style="min-width: 10em;"/>
									</colgroup>
									<tr><td>Blocked count</td><td>{{thread.blockedCount}}</td></tr>
									<tr><td>Blocked time</td><td>{{thread.blockedTime}}</td></tr>		
									<tr><td>Waited count</td><td>{{thread.waitedCount}}</td></tr>
									<tr><td>Waited time</td><td>{{thread.waitedTime}}</td></tr>
								</table>
								<table class="col-md-6">
									<colgroup>
										<col style="min-width: 10em;"/>
									</colgroup>
									<tr><td>Lock name</td><td>{{thread.lockName}}</td></tr>
									<tr><td>Lock owner id</td><td>{{thread.lockOwnerId}}</td></tr>				
									<tr><td>Lock owner name</td><td>{{thread.lockOwnerName}}</td></tr>
								</table>
							</div>
						</div>
<pre style="overflow: auto; max-height: 20em" ng-if="thread.stackTrace"><span ng-repeat="el in thread.stackTrace">{{el.className}}.{{el.methodName}}({{el.fileName}}:{{el.lineNumber}}) <span class="label label-default" ng-if="el.nativeMethod">native</span>
</span></pre>
				</accordion-group>
			</accordion>
		</div>
	</div>
</div>